package com.qixiucoding.strategy.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.qixiucoding.link.AbstractLink;
import com.qixiucoding.link.inherit.StratLink;
import com.qixiucoding.link.inherit.dao.Dao1Inherit;
import com.qixiucoding.link.inherit.dao.Dao2Inherit;
import com.qixiucoding.link.inherit.field.FieldF1Inherit;
import com.qixiucoding.strategy.IStrategy;
import com.qixiucoding.strategy.StrategyName;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author longhj
 * @Description TODO
 * @Date 2021/10/24 星期日 17:58
 */
@Component
@StrategyName(strategyName = "A策略")
@Slf4j
public class AStrategy implements IStrategy {
    @Autowired
    private FieldF1Inherit fieldF1Inherit;
    @Autowired
    private Dao2Inherit dao2Inherit;
    @Override
    public JSONObject dealData(JSONObject jsonObject) {
        String s = this.getClass().getAnnotation(StrategyName.class).strategyName();
        if (StringUtils.isBlank(s)) {
            log.error("策略AStrategy获取名称失败，请加入@StrategyName定义名称！");
        }
        JSONObject object = jsonObject.getJSONObject(s);
        jsonObject.put("Wind1745",object);
        jsonObject.remove(s);

        AbstractLink abstractLink = fieldF1Inherit.appendNext(dao2Inherit);
        JSONObject result = new StratLink().start(jsonObject, fieldF1Inherit);
        return result;
    }
}
